<style lang="less">
	@import "../../../styles/table-common.less";
// @import "./userManage.less";
</style>
<template>
	<div class="search">
		<div id="StatusArea" v-show="false"></div>
		<Card>
			<Row v-show="openSearch" @keydown.enter.native="handleSearch">
				<Form ref="searchForm" :model="searchForm" inline :label-width="70">
					<Form-item label="用户名" prop="nickname">
						<department-choose @on-change="handleSelectDep" style="width: 150px" ref="dep"></department-choose>
					</Form-item>
					<Form-item label="部门" prop="department">
						<department-choose @on-change="handleSelectDep" style="width: 150px" ref="dep"></department-choose>
					</Form-item>
					<!-- <span v-if="drop">
            <Form-item label="手机号" prop="mobile">
              <Input
                type="text"
                v-model="searchForm.mobile"
                clearable
                placeholder="请输入手机号"
                style="width: 200px"
              />
            </Form-item>
            <Form-item label="邮箱" prop="email">
              <Input
                type="text"
                v-model="searchForm.email"
                clearable
                placeholder="请输入邮箱"
                style="width: 200px"
              />
            </Form-item>
            <Form-item label="性别" prop="sex">
              <Select v-model="searchForm.sex" placeholder="请选择" clearable style="width: 200px">
                <Option v-for="(item, i) in dictSex" :key="i" :value="item.value">{{item.title}}</Option>
              </Select>
            </Form-item>
            <Form-item label="登录账号" prop="username">
              <Input
                type="text"
                v-model="searchForm.username"
                clearable
                placeholder="请输入登录账号"
                style="width: 200px"
              />
            </Form-item>
            <Form-item label="用户ID" prop="id">
              <Input
                type="text"
                v-model="searchForm.id"
                clearable
                placeholder="请输入用户ID"
                style="width: 200px"
              />
            </Form-item>
            <Form-item label="创建时间">
              <DatePicker
                v-model="selectDate"
                type="daterange"
                format="yyyy-MM-dd"
                clearable
                @on-change="selectDateRange"
                placeholder="选择起始时间"
                style="width: 200px"
              ></DatePicker>
            </Form-item>
          </span> -->
					<Form-item style="margin-left:-35px;" class="br">
						<Button @click="add" type="primary">已收藏客户</Button>
						<Button @click="delAll" icon="md-trash">收藏客户</Button>
						<Button>
							移入公海
							<Icon type="md-add" />
						</Button>
						<Button @click="openDev" icon="md-trash">打开设备</Button>
						<Button @click="closeDev" icon="md-trash">关闭设备</Button>
					</Form-item>
				</Form>
			</Row>
			<!-- <Row class="operation">
        <Dropdown @on-click="handleDropdown">
          <DropdownMenu slot="list">
            <DropdownItem name="refresh">刷新</DropdownItem>
            <DropdownItem name="reset">重置用户密码</DropdownItem>
            <DropdownItem name="exportData">导出所选数据</DropdownItem>
            <DropdownItem name="exportAll">导出全部数据</DropdownItem>
            <DropdownItem name="importData">导入数据(付费)</DropdownItem>
          </DropdownMenu>
        </Dropdown>
      </Row> -->
			<!-- <Row v-show="openTip">
        <Alert show-icon>
          已选择
          <span class="select-count">{{selectCount}}</span> 项
          <a class="select-clear" @click="clearSelectAll">清空</a>
        </Alert>
      </Row> -->
			<Modal v-model="modal" width="360" :closable="false" :mask-closable="false">
				<p slot="header" style="color:#f60;text-align:center">
					<Icon type="information-circled"></Icon>
					<span>{{callObj.name}}</span>
				</p>
				<div style="text-align:center">
					<p>通话中。。</p>
					<p>{{hour+':'+minute+':'+second}}</p>
				</div>
				<div slot="footer">
					<i-button type="error" size="large" long @click="hangUp">
						挂断
					</i-button>
				</div>
			</Modal>
			<!-- <Modal v-model="saveModal" width="360" :closable="false" :mask-closable="false">
				<p slot="header" style="color:#f60;text-align:center">
					<Icon type="information-circled"></Icon>
					<span>{{callObj.name}}</span>
				</p>
				<div style="text-align:center">
					<p>通话中。。</p>
					<p>{{hour+':'+minute+':'+second}}</p>
				</div>
				<div slot="footer">
					<i-button type="error" size="large" long :loading="modal_loading" @click="hangUp">
						挂断
					</i-button>
				</div>
			</Modal> -->
			<Row>
				<Table border :columns="columns" :data="data" sortable="custom" @on-sort-change="changeSort" @on-selection-change="showSelect"
				 ref="table"></Table>
				<!-- <Table :columns="exportColumns" :data="exportData" ref="exportTable" style="display:none"></Table> -->
			</Row>
			<Row type="flex" justify="end" class="page">
				<Page :current="searchForm.pageNumber" :total="total" :page-size="searchForm.pageSize" @on-change="changePage"
				 @on-page-size-change="changePageSize" :page-size-opts="[10,20,50]" size="small" show-total show-elevator
				 show-sizer></Page>
			</Row>
		</Card>


		<Modal v-model="modalExportAll" title="确认导出" :loading="loadingExport" @on-ok="exportAll">
			<p>您确认要导出全部 {{total}} 条数据？</p>
		</Modal>

		<check-password ref="checkPass" @on-success="resetPass" />

	</div>
</template>

<script>
	window.unload = function() {
		$(document).ready(function() {
			TV_Initialize();
			getEvent(T_GetEvent);
		});
		$(window).unload(function() {
			TV_Disable();
		});
		//离开页面
		$(window).bind('beforeunload', function() {;
			TV_Disable();
		});
	}

	function AppendStatus(szStatus) {
		//qnviccub.QNV_Tool(QNV_TOOL_WRITELOG,0,szStatus,NULL,NULL,0);//写本地日志到控件注册目录的userlog目录下
		$("#StatusArea").append(szStatus + "\r\n");
		var scrollTop = $("#StatusArea")[0].scrollHeight;
		$("#StatusArea").scrollTop(scrollTop);
		//var szHint = $("#StatusArea").val()+ szStatus +"\r\n";
		// $("#StatusArea").val(szHint);
		//  $("#StatusArea").scrollTop($("#StatusArea").scrollHeight());
	}

	function AppendStatusEx(uID, szStatus) {
		uID = uID + 1;
		AppendStatus("通道" + uID + ":" + szStatus);
	}

	function showDlg(flag) {
		var urlStr = prompt("请输入上传的文件的URL，格式如php文件上传", "");
		if (urlStr != null && urlStr != "") {
			if (flag == 0)
				TV_uploadFile(urlStr);
			else
				ali_uploadFile(urlStr);
		} else {
			alert('上传url不能为空!');
		}
	}

	function T_GetEvent(uID, uEventType, uHandle, uResult, szdata) {
		//var vValueArray=qnviccub.QNV_Event(0,2,0,"","",1024);
		if (uEventType == -1)
			return;
		var vValue = " type=" + uEventType + " Handle=" + uHandle + " Result=" + uResult + " szdata=" + szdata;
		switch (uEventType) {
			case BriEvent_PhoneHook: // 本地电话机摘机事件
				AppendStatusEx(uID, "本地电话机摘机" + vValue);
				break;
			case BriEvent_PhoneDial: // 只有在本地话机摘机，没有调用软摘机时，检测到DTMF拨号
				AppendStatusEx(uID, "本地话机拨号" + vValue);
				break;
			case BriEvent_PhoneHang: // 本地电话机挂机事件
				TV_HangUpCtrl(uID);
				AppendStatusEx(uID, "本地电话机挂机" + vValue);
				break;
			case BriEvent_CallIn: // 外线通道来电响铃事件
				AppendStatusEx(uID, "外线通道来电响铃事件" + vValue);
				break;
			case BriEvent_GetCallID: //得到来电号码
				AppendStatusEx(uID, "得到来电号码" + vValue);
				break;
			case BriEvent_StopCallIn: // 对方停止呼叫(产生一个未接电话)
				AppendStatusEx(uID, "对方停止呼叫(产生一个未接电话)" + vValue);
				break;
			case BriEvent_DialEnd: // 调用开始拨号后，全部号码拨号结束
				AppendStatusEx(uID, "调用开始拨号后，全部号码拨号结束" + vValue);
				break;
			case BriEvent_PlayFileEnd: // 播放文件结束事件
				AppendStatusEx(uID, "播放文件结束事件" + vValue);
				break;
			case BriEvent_PlayMultiFileEnd: // 多文件连播结束事件
				AppendStatusEx(uID, "多文件连播结束事件" + vValue);
				break;
			case BriEvent_PlayStringEnd: //播放字符结束
				AppendStatusEx(uID, "播放字符结束" + vValue);
				break
			case BriEvent_RepeatPlayFile: // 播放文件结束准备重复播放
				AppendStatusEx(uID, "播放文件结束准备重复播放" + vValue);
				break;
			case BriEvent_SendCallIDEnd: // 给本地设备发送震铃信号时发送号码结束
				AppendStatusEx(uID, "给本地设备发送震铃信号时发送号码结束" + vValue);
				break;
			case BriEvent_RingTimeOut: //给本地设备发送震铃信号时超时
				AppendStatusEx(uID, "给本地设备发送震铃信号时超时" + vValue);
				break;
			case BriEvent_Ringing: //正在内线震铃
				AppendStatusEx(uID, "正在内线震铃" + vValue);
				break;
			case BriEvent_Silence: // 通话时检测到一定时间的静音.默认为5秒
				AppendStatusEx(uID, "通话时检测到一定时间的静音" + vValue);
				break;
			case BriEvent_GetDTMFChar: // 线路接通时收到DTMF码事件
				AppendStatusEx(uID, "线路接通时收到DTMF码事件" + vValue);
				break;
			case BriEvent_RemoteHook: // 拨号后,被叫方摘机事件
				AppendStatusEx(uID, "拨号后,被叫方摘机事件" + vValue);
				break;
			case BriEvent_RemoteHang: //对方挂机事件
				TV_HangUpCtrl(uID);
				AppendStatusEx(uID, "对方挂机事件" + vValue);
				break;
			case BriEvent_Busy: // 检测到忙音事件,表示PSTN线路已经被断开
				AppendStatusEx(uID, "检测到忙音事件,表示PSTN线路已经被断开" + vValue);
				break;
			case BriEvent_DialTone: // 本地摘机后检测到拨号音
				AppendStatusEx(uID, "本地摘机后检测到拨号音" + vValue);
				break;
			case BriEvent_RingBack: // 电话机拨号结束呼出事件。
				AppendStatusEx(uID, "电话机拨号结束呼出事件" + vValue);
				break;
			case BriEvent_MicIn: // MIC插入状态
				AppendStatusEx(uID, "MIC插入状态" + vValue);
				break;
			case BriEvent_MicOut: // MIC拔出状态
				AppendStatusEx(uID, "MIC拔出状态" + vValue);
				break;
			case BriEvent_FlashEnd: // 拍插簧(Flash)完成事件，拍插簧完成后可以检测拨号音后进行二次拨号
				AppendStatusEx(uID, "拍插簧(Flash)完成事件，拍插簧完成后可以检测拨号音后进行二次拨号" + vValue);
				break;
			case BriEvent_RefuseEnd: // 拒接完成
				AppendStatusEx(uID, "拒接完成" + vValue);
				break;
			case BriEvent_SpeechResult: // 语音识别完成 
				AppendStatusEx(uID, "语音识别完成" + vValue);
				break;
			case BriEvent_FaxRecvFinished: // 接收传真完成
				AppendStatusEx(uID, "接收传真完成" + vValue);
				break;
			case BriEvent_FaxRecvFailed: // 接收传真失败
				AppendStatusEx(uID, "接收传真失败" + vValue);
				break;
			case BriEvent_FaxSendFinished: // 发送传真完成
				AppendStatusEx(uID, "发送传真完成" + vValue);
				break;
			case BriEvent_FaxSendFailed: // 发送传真失败
				AppendStatusEx(uID, "发送传真失败" + vValue);
				break;
			case BriEvent_OpenSoundFailed: // 启动声卡失败
				AppendStatusEx(uID, "启动声卡失败" + vValue);
				break;
			case BriEvent_UploadSuccess: //远程上传成功
				AppendStatusEx(uID, "远程上传成功" + vValue);
				break;
			case BriEvent_UploadFailed: //远程上传失败
				AppendStatusEx(uID, "远程上传失败" + vValue);
				break;
			case BriEvent_EnableHook: // 应用层调用软摘机/软挂机成功事件
				AppendStatusEx(uID, "应用层调用软摘机/软挂机成功事件" + vValue);
				break;
			case BriEvent_EnablePlay: // 喇叭被打开或者/关闭
				AppendStatusEx(uID, "喇叭被打开或者/关闭" + vValue);
				break;
			case BriEvent_EnableMic: // MIC被打开或者关闭
				AppendStatusEx(uID, "MIC被打开或者关闭" + vValue);
				break;
			case BriEvent_EnableSpk: // 耳机被打开或者关闭
				AppendStatusEx(uID, "耳机被打开或者关闭" + vValue);
				break;
			case BriEvent_EnableRing: // 电话机跟电话线(PSTN)断开/接通
				AppendStatusEx(uID, "电话机跟电话线(PSTN)断开/接通" + vValue);
				break;
			case BriEvent_DoRecSource: // 修改录音源
				AppendStatusEx(uID, "修改录音源" + vValue);
				break;
			case BriEvent_DoStartDial: // 开始软件拨号
				AppendStatusEx(uID, "开始软件拨号" + vValue);
				break;
			case BriEvent_RecvedFSK: // 接收到FSK信号，包括通话中FSK/来电号码的FSK
				AppendStatusEx(uID, "接收到FSK信号，包括通话中FSK/来电号码的FSK" + vValue);
				break;
			case BriEvent_PlugOut:
				AppendStatusEx(uID, "设备移除");
				break;
			case BriEvent_DevErr: //设备错误
				AppendStatusEx(uID, "设备错误" + decodeURIComponent(vValue));
				break;
			default:
				if (uEventType < BriEvent_EndID)
					AppendStatusEx(uID, "忽略其它事件发生:ID=" + uEventType + vValue);
				break;
		}

	}

	//编码问题
	var base64EncodeChars = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
	var base64DecodeChars = new Array(

		-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,

		-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,

		-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 62, -1, -1, -1, 63,

		52, 53, 54, 55, 56, 57, 58, 59, 60, 61, -1, -1, -1, -1, -1, -1,

		-1, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14,

		15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, -1, -1, -1, -1, -1,

		-1, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40,

		41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, -1, -1, -1, -1, -1);

	function base64encode(str) {

		var out, i, len;

		var c1, c2, c3;

		len = str.length;

		i = 0;

		out = "";

		while (i < len) {

			c1 = str.charCodeAt(i++) & 0xff;

			if (i == len)

			{

				out += base64EncodeChars.charAt(c1 >> 2);

				out += base64EncodeChars.charAt((c1 & 0x3) << 4);

				out += "==";

				break;

			}

			c2 = str.charCodeAt(i++);

			if (i == len)

			{

				out += base64EncodeChars.charAt(c1 >> 2);

				out += base64EncodeChars.charAt(((c1 & 0x3) << 4) | ((c2 & 0xF0) >> 4));

				out += base64EncodeChars.charAt((c2 & 0xF) << 2);

				out += "=";

				break;

			}

			c3 = str.charCodeAt(i++);

			out += base64EncodeChars.charAt(c1 >> 2);

			out += base64EncodeChars.charAt(((c1 & 0x3) << 4) | ((c2 & 0xF0) >> 4));

			out += base64EncodeChars.charAt(((c2 & 0xF) << 2) | ((c3 & 0xC0) >> 6));

			out += base64EncodeChars.charAt(c3 & 0x3F);

		}

		return out;

	}

	function base64decode(str) {

		var c1, c2, c3, c4;

		var i, len, out;

		len = str.length;

		i = 0;

		out = "";

		while (i < len) {

			/* c1 */

			do {

				c1 = base64DecodeChars[str.charCodeAt(i++) & 0xff];

			} while (i < len && c1 == -1);

			if (c1 == -1)

				break;

			/* c2 */

			do {

				c2 = base64DecodeChars[str.charCodeAt(i++) & 0xff];

			} while (i < len && c2 == -1);

			if (c2 == -1)

				break;

			out += String.fromCharCode((c1 << 2) | ((c2 & 0x30) >> 4));

			/* c3 */

			do {

				c3 = str.charCodeAt(i++) & 0xff;

				if (c3 == 61)

					return out;

				c3 = base64DecodeChars[c3];

			} while (i < len && c3 == -1);

			if (c3 == -1)

				break;

			out += String.fromCharCode(((c2 & 0XF) << 4) | ((c3 & 0x3C) >> 2));

			/* c4 */

			do {

				c4 = str.charCodeAt(i++) & 0xff;

				if (c4 == 61)

					return out;

				c4 = base64DecodeChars[c4];

			} while (i < len && c4 == -1);

			if (c4 == -1)

				break;

			out += String.fromCharCode(((c3 & 0x03) << 6) | c4);

		}

		return out;

	}

	function utf16to8(str) {

		var out, i, len, c;

		out = "";

		len = str.length;

		for (i = 0; i < len; i++) {

			c = str.charCodeAt(i);

			if ((c >= 0x0001) && (c <= 0x007F)) {

				out += str.charAt(i);

			} else if (c > 0x07FF) {

				out += String.fromCharCode(0xE0 | ((c >> 12) & 0x0F));

				out += String.fromCharCode(0x80 | ((c >> 6) & 0x3F));

				out += String.fromCharCode(0x80 | ((c >> 0) & 0x3F));

			} else {

				out += String.fromCharCode(0xC0 | ((c >> 6) & 0x1F));

				out += String.fromCharCode(0x80 | ((c >> 0) & 0x3F));

			}

		}

		return out;

	}

	function utf8to16(str) {

		var out, i, len, c;

		var char2, char3;

		out = "";

		len = str.length;

		i = 0;

		while (i < len) {

			c = str.charCodeAt(i++);

			switch (c >> 4)

			{

				case 0:
				case 1:
				case 2:
				case 3:
				case 4:
				case 5:
				case 6:
				case 7:

					// 0xxxxxxx

					out += str.charAt(i - 1);

					break;

				case 12:
				case 13:

					// 110x xxxx　 10xx xxxx

					char2 = str.charCodeAt(i++);

					out += String.fromCharCode(((c & 0x1F) << 6) | (char2 & 0x3F));

					break;

				case 14:

					// 1110 xxxx　10xx xxxx　10xx xxxx

					char2 = str.charCodeAt(i++);

					char3 = str.charCodeAt(i++);

					out += String.fromCharCode(((c & 0x0F) << 12) |

						((char2 & 0x3F) << 6) |

						((char3 & 0x3F) << 0));

					break;

			}

		}

		return out;

	}
	import {
		getUserListData,
		enableUser,
		disableUser,
		deleteUser,
		getAllUserData,
		resetUserPass,
		getPublicUsers,
		selectPublicUsers
	} from "@/api/index";
	import {
		validateMobile
	} from "@/libs/validate";
	import departmentChoose from "../../my-components/xboot/department-choose";
	import checkPassword from "@/views/my-components/xboot/check-password";
	export default {
		name: "user-manage",
		components: {
			departmentChoose,
			checkPassword,
		},
		data() {
			return {
				// isDisabled:true,
				saveModal:false,
				timer:'',
				time:0,
				hour:'',
				minute:'',
				second:'',
				modal: false,
				height: 510,
				showUser: false,
				showType: "0",
				loading: true,
				openSearch: true,
				openTip: true,
				operationLoading: false,
				loadingExport: true,
				modalExportAll: false,
				drop: false,
				dropDownContent: "展开",
				dropDownIcon: "ios-arrow-down",
				selectCount: 0,
				selectList: [],
				dataDep: [],
				searchKey: "",
				callObj: {},
				searchForm: {
					id: "",
					nickname: "",
					username: "",
					departmentId: "",
					mobile: "",
					email: "",
					sex: "",
					type: "",
					status: "",
					pageNumber: 1,
					pageSize: 10,
					sort: "createTime",
					order: "desc",
					startDate: "",
					endDate: ""
				},
				form: {},
				columns: [
					// {
					//   type: "selection",
					//   width: 60,
					//   align: "center",
					//   fixed: "left"
					// },
					{
					  type: "index",
					  width: 60,
					  align: "center",
					  fixed: "left"
					},
					{
						title: "姓名",
						key: "name",
						minWidth: 125,
						sortable: true,
						// fixed: "left"
					},
					{
						title: "手机号",
						key: "telephone",
						minWidth: 125,
						sortable: true,
						// fixed: "left",
						// render: (h, params) => {
						//   return h(
						//     "a",
						//     {
						//       on: {
						//         click: () => {
						//           this.showDetail(params.row);
						//         }
						//       }
						//     },
						//     params.row.nickname
						//   );
						// }
					},
					// {
					//   title: "通话总时长",
					//   key: "avatar",
					//   width: 80,
					//   align: "center",
					//   render: (h, params) => {
					//     return h("Avatar", {
					//       props: {
					//         src: params.row.avatar
					//       }
					//     });
					//   }
					// },
					{
						title: "创建时间",
						key: "cts",
						sortable: true,
						sortType: "desc",
						width: 180
					},
					{
						title: "修改时间",
						key: "uts",
						sortable: true,
						sortType: "desc",
						minWidth: 125
					},
					// {
					//   title: "意向情况",
					//   key: "mobile",
					//   minWidth: 125,
					//   sortable: true
					// },

					{
						title: "操作",
						key: "action",
						minWidth: 125,
						align: "center",
						fixed: "right",
						render: (h, params) => {
							let enableOrDisable = "";
							if (params.row.status == 0) {
								enableOrDisable = h(
									"Button", {
										props: {
											size: "small"
										},
										style: {
											marginRight: "5px"
										},
										on: {
											click: () => {
												this.disable(params.row);
											}
										}
									},
									"禁用"
								);
							} else {
								enableOrDisable = h(
									"Button", {
										props: {
											type: "success",
											size: "small"
										},
										style: {
											marginRight: "5px"
										},
										on: {
											click: () => {
												this.enable(params.row);
											}
										}
									},
									"启用"
								);
							}
							return h("div", [
								h(
									"Button", {
										props: {
											type: "primary",
											size: "small",
											// disabled:this.isDisabled
										},
										style: {
											marginRight: "5px"
										},
										on: {
											click: () => {
												this.modal = true
												this.callObj = params.row
												// this.timer = setInterval(()=>{
													// this.time ++
													// this.hour = parseInt(time / 60 / 60 % 24);//小时
													// this.minute = parseInt(time/ 60 % 60);//分钟
													// this.seconds = parseInt(time % 60);//秒
												// },1000)
												// console.log(this.timer)
												// this.callObj.telephone
												TV_StartDial(0,this.callObj.telephone)
												TV_StartRecordFile(0)
												
											}
										}
									},
									"拨打"
								),
								enableOrDisable,
								h(
									"Button", {
										props: {
											type: "error",
											size: "small"
										},
										on: {
											click: () => {
												this.remove(params.row);
											}
										}
									},
									"删除"
								)
							]);
						}
					}
				],
				exportColumns: [{
						title: "用户名",
						key: "username"
					},
					{
						title: "头像",
						key: "avatar"
					},
					{
						title: "所属部门ID",
						key: "departmentId"
					},
					{
						title: "所属部门",
						key: "departmentTitle"
					},
					{
						title: "手机",
						key: "mobile"
					},
					{
						title: "邮箱",
						key: "email"
					},
					{
						title: "性别",
						key: "sex"
					},
					{
						title: "用户类型",
						key: "type"
					},
					{
						title: "状态",
						key: "status"
					},
					{
						title: "删除标志",
						key: "delFlag"
					},
					{
						title: "创建时间",
						key: "createTime"
					},
					{
						title: "更新时间",
						key: "updateTime"
					}
				],
				data: [],
				exportData: [],
				total: 0,
				dictSex: this.$store.state.dict.sex
			};
		},
		methods: {
			hangUp(){
				TV_HangUpCtrl(0)
				TV_StopRecordFile(0)
				// this.upLoadFile()
				this.modal = false
				this.saveModal = true
			},
			closeDev(){
				// this.isDisabled=true
				CloseDevice(ODT_LBRIDGE,function(nResult){AppendStatus('关闭设备.');})
				TV_EnableMic(0,FALSE)
				TV_EnableLine2Spk(0,FALSE)
				TV_CloseDoPlay(0)
			},
			openDev() {
				// this.isDisabled=false
				OpenDevice(ODT_LBRIDGE, function(nResult) {
					AppendStatus('打开设备.');
				})
				TV_EnableMic(0,TRUE)
				TV_EnableLine2Spk(0,TRUE)
				TV_OpenDoPlay(0)
			},
			upLoadFile(){
				
			},
			cancel() {
				this.$Message.info('点击了取消');
			},
			init() {
				this.getUserList();
			},
			handleSelectDep(v) {
				this.searchForm.departmentId = v;
			},
			changePage(v) {
				this.searchForm.pageNumber = v;
				this.selectPublicUsers()
			},
			changePageSize(v) {
				this.searchForm.pageSize = v;
				this.getUserList();
			},
			selectDateRange(v) {
				if (v) {
					this.searchForm.startDate = v[0];
					this.searchForm.endDate = v[1];
				}
			},
			getUserList() {
				// 多条件搜索用户列表
				// this.loading = true;
				// getUserListData(this.searchForm).then(res => {
				//   this.loading = false;
				//   if (res.success) {
				//     this.data = res.result.content;
				//     this.total = res.result.totalElements;
				//   }
				// });
			},
			handleSearch() {
				this.searchForm.pageNumber = 1;
				this.searchForm.pageSize = 10;
				this.getUserList();
			},
			handleReset() {
				this.$refs.searchForm.resetFields();
				this.searchForm.pageNumber = 1;
				this.searchForm.pageSize = 10;
				this.selectDate = null;
				this.searchForm.startDate = "";
				this.searchForm.endDate = "";
				this.selectDep = [];
				this.searchForm.departmentId = "";
				// 重新加载数据
				this.getUserList();
			},
			changeSort(e) {
				this.searchForm.sort = e.key;
				this.searchForm.order = e.order;
				if (e.order == "normal") {
					this.searchForm.order = "";
				}
				this.getUserList();
			},
			getRoleList() {
				getAllRoleList().then(res => {
					if (res.success) {
						this.roleList = res.result;
					}
				});
			},
			handleDropdown(name) {
				if (name == "refresh") {
					this.getUserList();
				} else if (name == "reset") {
					if (this.selectCount <= 0) {
						this.$Message.warning("您还未选择要重置密码的用户");
						return;
					}
					this.$refs.checkPass.show();
				} else if (name == "exportData") {
					if (this.selectCount <= 0) {
						this.$Message.warning("您还未选择要导出的数据");
						return;
					}
					this.$Modal.confirm({
						title: "确认导出",
						// content: "您确认要导出所选 " + this.selectCount + " 条数据?",
						onOk: () => {
							this.$refs.exportTable.exportCsv({
								filename: "用户数据"
							});
						}
					});
				} else if (name == "exportAll") {
					this.modalExportAll = true;
				} else if (name == "importData") {
					this.$Modal.info({
						title: "请获取完整版",
						// content: "支付链接: http://xpay.exrick.cn/pay?xboot"
					});
				}
			},
			exportAll() {
				getAllUserData().then(res => {
					this.modalExportAll = false;
					if (res.success) {
						this.exportData = res.result;
						setTimeout(() => {
							this.$refs.exportTable.exportCsv({
								filename: "用户全部数据"
							});
						}, 1000);
					}
				});
			},
			resetPass() {
				this.$Modal.confirm({
					title: "确认重置",
					// content:
					//   "您确认要重置所选的 " +
					//   this.selectCount +
					//   " 条用户数据密码为【123456】?",
					loading: true,
					onOk: () => {
						let ids = "";
						this.selectList.forEach(function(e) {
							ids += e.id + ",";
						});
						ids = ids.substring(0, ids.length - 1);
						resetUserPass({
							ids: ids
						}).then(res => {
							this.$Modal.remove();
							if (res.success) {
								this.$Message.success("操作成功");
								this.clearSelectAll();
								this.getUserList();
							}
						});
					}
				});
			},
			showDetail(v) {
				// 转换null为""
				for (let attr in v) {
					if (v[attr] == null) {
						v[attr] = "";
					}
				}
				let str = JSON.stringify(v);
				let data = JSON.parse(str);
				this.form = data;
				this.showType = "0";
				this.showUser = true;
			},
			add() {
				this.showType = "2";
				this.showUser = true;
			},
			edit(v) {
				// 转换null为""
				for (let attr in v) {
					if (v[attr] == null) {
						v[attr] = "";
					}
				}
				let str = JSON.stringify(v);
				let data = JSON.parse(str);
				this.form = data;
				this.showType = "1";
				this.showUser = true;
			},
			enable(v) {
				this.$Modal.confirm({
					title: "确认启用",
					// content: "您确认要启用用户 " + v.username + " ?",
					loading: true,
					onOk: () => {
						enableUser(v.id).then(res => {
							this.$Modal.remove();
							if (res.success) {
								this.$Message.success("操作成功");
								this.getUserList();
							}
						});
					}
				});
			},
			disable(v) {
				this.$Modal.confirm({
					title: "确认禁用",
					// content: "您确认要禁用用户 " + v.username + " ?",
					loading: true,
					onOk: () => {
						disableUser(v.id).then(res => {
							this.$Modal.remove();
							if (res.success) {
								this.$Message.success("操作成功");
								this.getUserList();
							}
						});
					}
				});
			},
			remove(v) {
				this.$Modal.confirm({
					title: "确认删除",
					// content: "您确认要删除用户 " + v.username + " ?",
					loading: true,
					onOk: () => {
						deleteUser({
							ids: v.id
						}).then(res => {
							this.$Modal.remove();
							if (res.success) {
								this.$Message.success("删除成功");
								this.getUserList();
							}
						});
					}
				});
			},
			dropDown() {
				if (this.drop) {
					this.dropDownContent = "展开";
					this.dropDownIcon = "ios-arrow-down";
				} else {
					this.dropDownContent = "收起";
					this.dropDownIcon = "ios-arrow-up";
				}
				this.drop = !this.drop;
			},
			showSelect(e) {
				this.exportData = e;
				this.selectList = e;
				this.selectCount = e.length;
			},
			clearSelectAll() {
				this.$refs.table.selectAll(false);
			},
			delAll() {
				if (this.selectCount <= 0) {
					this.$Message.warning("您还未选择要删除的数据");
					return;
				}
				this.$Modal.confirm({
					title: "确认删除",
					// content: "您确认要删除所选的 " + this.selectCount + " 条数据?",
					loading: true,
					onOk: () => {
						let ids = "";
						this.selectList.forEach(function(e) {
							ids += e.id + ",";
						});
						ids = ids.substring(0, ids.length - 1);
						deleteUser({
							ids: ids
						}).then(res => {
							this.$Modal.remove();
							if (res.success) {
								this.$Message.success("删除成功");
								this.clearSelectAll();
								this.getUserList();
							}
						});
					}
				});
			},

			
			selectPublicUsers() {
				selectPublicUsers({
					page:this.searchForm.pageNumber,
					limit:this.searchForm.pageSize
				}).then(res => {
					this.data = res.data
					this.total = res.total
				})
			}

		},
		mounted() {
			this.selectPublicUsers()
			// 计算高度
			this.height = Number(document.documentElement.clientHeight - 230);
			this.init();
		}
	};
</script>
